package com.example.controller.auth;

import com.alibaba.fastjson.JSONObject;
import com.example.config.ribbon.ServiceDiscoveryService;
import com.example.feign.NodeFeignService;
import com.example.util.Results;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "节点服务")
@RestController
@RequestMapping("/node")
public class NodeController {

    @Autowired
    private ServiceDiscoveryService discoveryService;

    @Autowired
    private NodeFeignService nodeFeignService;

    @GetMapping("/serviceAll")
    public JSONObject nodeListService() {
        List<String> stringList=discoveryService.getAllServices();
        return Results.success(stringList);
    }

    @PostMapping("/saveorupdate")
    public JSONObject saveOrUpdate(@RequestBody JSONObject jsonObject) {
        return nodeFeignService.saveOrUpdateDataNode(jsonObject);
    }
}
